package com.my.shetuan.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.my.shetuan.controller.utils.SYSTENET;
import com.my.shetuan.entity.Student;
import com.my.shetuan.mapper.StudentMapper;
import com.my.shetuan.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-09-02
 */
@Controller
@RequestMapping("/shetuan/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @GetMapping("/delete/{id}")
    public String deleteId(@PathVariable Integer id,HttpSession session){
        if(studentService.removeById(id)){
            session.setAttribute("tishi","删除成功");
            return "redirect:/dynamic_table";
        }
        session.setAttribute("tishi","删除失败");
        return null;
    }

    @PostMapping("/create")
    public String create(Student student, HttpSession session){
        if (studentService.save(student)){
            return "/index";
        }
        return null;
    }

}

